//
//  MessageViewController.m
//  meiyinxiang
//
//  Created by apple on 2017/10/17.
//  Copyright © 2017年 hbjApple. All rights reserved.
//  我的消息

#import "MessageViewController.h"
#import "MYY_MessageCell.h"
#import "MYY_MessageMarco.h"
#import "MYYMessageModel.h"
#import "MYXMoneyComesViewController.h"
#import "MYXsystemNewViewController.h"
#import "MYXSessionListViewController.h"
@interface MessageViewController ()<UITableViewDataSource,UITableViewDelegate,UIAlertViewDelegate>{
     NSMutableArray *titleArray;//文字数组
}
@property (nonatomic, strong)UITableView * m_tabView ;
@property (nonatomic, strong) NSMutableArray *dataArr;

@end

@implementation MessageViewController
-(NSMutableArray *)dataArr
{
    if (!_dataArr) {
        _dataArr = [NSMutableArray array];
    }
    return _dataArr;
}
-(void)initload {
    [self.dataArr removeAllObjects];
    titleArray= [NSMutableArray arrayWithArray:@[@{
                                                     @"thum": @"xiaoxi_qianlaiqianwang",
                                                     @"title": @"钱来钱往",
                                                     @"content": @"查看您的金钱来往",
                                                     @"anew" : @"0" },
                                                   @{@"thum": @"xiaoxi_xiaomeimishu",
                                                     @"title": @"小媒秘书",
                                                     @"content": @"请问您有什么要咨询的吗？",
                                                     @"anew" : @"3" },
                                                   @{
                                                     @"thum": @"xiaoxi_xitonggonggao",
                                                     @"title": @"系统公告",
                                                     @"content": @"您想成为雇主吗？",
                                                     @"placeholder" : @"身份证" }
                                                   ,
                                                   @{
                                                     @"thum": @"xiaoxi_hudong",
                                                     @"title": @"朋友互动",
                                                     @"content": @"请问您有什么要咨询的吗？",
                                                     @"anew" : @"2" },
                                                   ]];
    NSArray *array =[MYYMessageModel mj_objectArrayWithKeyValuesArray:titleArray];
    [self.dataArr addObjectsFromArray:array];
    [self.m_tabView reloadData];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initload];
    [self createUI];
   
    
    
    
}
#pragma mark - UI

- (void)createUI
{
    [self.view addSubview:self.m_tabView];
}

#pragma mark -我的消息列表

-(UITableView *)m_tabView
{
    if (!_m_tabView)
    {
        _m_tabView = [[UITableView alloc]initWithFrame:CGRectMake(0,0, WIDTH, HEIGHT) style:UITableViewStylePlain];
        _m_tabView.backgroundColor =  [UIColor whiteColor];
        _m_tabView.separatorStyle=UITableViewCellSeparatorStyleNone;
        _m_tabView.showsVerticalScrollIndicator = NO;
        _m_tabView.dataSource = self;
        _m_tabView.delegate = self;
        WS(weakSelf)
    }
    return _m_tabView;
}
#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return  1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MYY_MessageCell *MessageCell = [MYY_MessageCell cellWithTableView:tableView];
    MessageCell.backgroundColor =[UIColor whiteColor];
    MessageCell.MYYMessageMode = self.dataArr[indexPath.row];
   
   
    return MessageCell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return MYY_Message_CELL_H;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *headView =[[UIView alloc]init];
    headView.frame = CGRectMake(0, 0, WIDTH, MYY_Message_CELL_TOP_H);
    headView.backgroundColor =MYYbgColor;
    
    UIImageView *_AvraImageView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 10, headView.frame.size.width-30, headView.frame.size.height-20)];
    _AvraImageView.image =[UIImage imageNamed:@"xiaoxi-sousuokuang"];
    [headView addSubview:_AvraImageView];
    
    UITapGestureRecognizer *tapScrollView = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(editContentT)];
    [_AvraImageView addGestureRecognizer:tapScrollView];
    
    return nil;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return MYY_Message_CELL_TOP_H;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    
    if (indexPath.row==0) {
        MYXMoneyComesViewController *MYXMoneyComesVC =[[MYXMoneyComesViewController alloc]init];
        MYXMoneyComesVC.navigationItem.title = @"钱来钱往";
        MYXMoneyComesVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:MYXMoneyComesVC animated:YES];

    }else if (indexPath.row==1){
        MYXsystemNewViewController *MYXsystemNewVC =[[MYXsystemNewViewController alloc]init];
        MYXsystemNewVC.navigationItem.title = @"系统互动";
        MYXsystemNewVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:MYXsystemNewVC animated:YES];
        
    }else if (indexPath.row==3){
        MYXSessionListViewController *vc = [[MYXSessionListViewController alloc] init];
        vc.navigationItem.title = @"聊天列表";
        vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:YES];
       
        
        
    }

    
    
    
}

-(void)editContentT{
    NSLog(@"000000");
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
